//
//  HZL_MusicTableViewCell.m
//  B_Project
//
//  Created by dllo on 15/12/4.
//  Copyright © 2015年 HZL. All rights reserved.
//

#import "HZL_MusicTableViewCell.h"
#import "UIImageView+WebCache.h"

@interface HZL_MusicTableViewCell ()
@property (nonatomic, retain) UIImageView *image;
@property (nonatomic, retain) UIImageView *black;
@property (nonatomic, retain) UILabel *titleLable;
@property (nonatomic, retain) UILabel *nickname;
@property (nonatomic, retain) UILabel *albumLable;
@property (nonatomic, retain) UILabel *likesLable;
@property (nonatomic, retain) UILabel *playCountsLable;
@property (nonatomic, retain) UILabel *score;
@property (nonatomic, retain) UILabel *indexLabel;
@property (nonatomic, retain) UIImageView *upOrDown;
@end
@implementation HZL_MusicTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    
    self.image =  [[UIImageView alloc] init];
    [self.contentView addSubview:self.image];
    
    self.black =  [[UIImageView alloc] init];
    self.black.backgroundColor = [UIColor blackColor];
    self.black.alpha = 0.4;
    [self.contentView addSubview:self.black];
    
    self.indexLabel = [[UILabel alloc] init];
    self.indexLabel.font = [UIFont boldSystemFontOfSize:20];
    self.indexLabel.textColor = [UIColor whiteColor];
    [self.contentView addSubview:self.indexLabel];
    
    self.upOrDown = [[UIImageView alloc] init];
    [self.contentView addSubview:self.upOrDown];
    
    self.titleLable = [[UILabel alloc] init];
    self.titleLable.textColor = [UIColor whiteColor];
    [self.contentView addSubview:self.titleLable];
    
    self.nickname = [[UILabel alloc] init];
    self.nickname.textColor = [UIColor grayColor];
    self.nickname.font = [UIFont systemFontOfSize:13];
    [self.contentView addSubview:self.nickname];
    
    self.score = [[UILabel alloc] init];
    self.score.text = @"0";
    self.score.font = [UIFont boldSystemFontOfSize:20];
    [self.contentView addSubview:self.score];
    
    
    return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    self.image.frame = CGRectMake(0, 0, 65, 65);
    self.black.frame = CGRectMake(0, 0, 65, 65);
    self.indexLabel.frame = CGRectMake(10, 17.5, 30, 30);
    self.indexLabel.text = [NSString stringWithFormat:@"%02ld", (long)self.index];
    self.upOrDown.frame = CGRectMake(65/2+5, 65/2 - 5, 15, 15);

    self.titleLable.frame = CGRectMake(75, 10, self.contentView.frame.size.width-70-80, 25);
    self.nickname.frame = CGRectMake(75, 40, 200, 25);
    self.score.frame = CGRectMake(self.contentView.frame.size.width - 70, 20, 55, 25);
    
    if ([self.rank_delta_list isEqualToString:@"fair"]) {
        self.score.textColor = [UIColor whiteColor];
        self.upOrDown.image = [UIImage imageNamed:@"iconfont-hengxian"];
    } if ([self.rank_delta_list isEqualToString:@"raise"]) {
        self.score.textColor = [UIColor redColor];
        self.upOrDown.image = [UIImage imageNamed:@"iconfont-sanjiaojiantoushang"];
    } else {
        self.score.textColor = [UIColor colorWithRed:28/255.0 green:175/255.0 blue:239/255.0 alpha:1];
        self.upOrDown.image = [UIImage imageNamed:@"iconfont-sanjiaojiantouxia"];
    }
}
- (void)setScore_list:(NSNumber *)score_list
{
    if (_score_list != score_list) {
        _score_list = score_list;
    }
    self.score.text = [NSString stringWithFormat:@"%@",self.score_list];
}
- (void)setModel:(HZL_MusicModel *)model
{
    if (_model != model) {
        _model = model;
    }
    
    [self.image sd_setImageWithURL:[NSURL URLWithString:model.cover]];
    self.titleLable.text = model.mediaName;
    self.nickname.text = model.author[@"nick"];
    
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
